/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * dlgAddStaff.java
 *
 * Created on Aug 23, 2012, 4:46:39 PM
 */

package Model.dialog;

import DataBase.DBManagerment;
import Processing.MD5Passing;
import Processing.PikaDate;
import Processing.dbclass.Staff;
import java.sql.Connection;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;

/**
 *
 * @author Admin
 */
public class dlgAddStaff extends javax.swing.JDialog {

    /** Creates new form dlgAddStaff */
    public dlgAddStaff(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        cbbStaffDepartment.setModel(db.getListDepartment(con));

        PikaDate piDAte = new PikaDate();
        cbbStaffYear.setModel(piDAte.getListYear());
    }

    /**
     * Đối tượng của class DBManagerment
     */
    private DBManagerment db = new DBManagerment();

    /**
     * Một Connection
     */
    private Connection con = db.ConnectServer();

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlStaffAdd = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        pssPassword = new javax.swing.JPasswordField();
        txtStaffUsername = new javax.swing.JTextField();
        pssPassConfirm = new javax.swing.JPasswordField();
        cbbStaffDepartment = new javax.swing.JComboBox();
        txtStaffLastName = new javax.swing.JTextField();
        txtStaffFirstName = new javax.swing.JTextField();
        txtStaffAddID = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        txtStaffPhoneNo = new javax.swing.JTextField();
        rdbStaffMale = new javax.swing.JRadioButton();
        jLabel10 = new javax.swing.JLabel();
        rdbStaffFemale = new javax.swing.JRadioButton();
        txtStaffEducation = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        cbbStaffSpecialization = new javax.swing.JComboBox();
        lblStaffSpecialization = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        taStaffAdress = new javax.swing.JTextArea();
        btnStaffAction = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        cbbStaffYear = new javax.swing.JComboBox();
        cbbStaffMonth = new javax.swing.JComboBox();
        cbbStaffDay = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Add Staff");

        pnlStaffAdd.setMaximumSize(new java.awt.Dimension(295, 560));
        pnlStaffAdd.setPreferredSize(new java.awt.Dimension(295, 560));

        jLabel1.setText("Staff's ID:");

        jLabel2.setText("First Name:");

        jLabel3.setText("Last Name:");

        jLabel4.setText("Department:");

        jLabel5.setText("Username:");

        jLabel6.setText("Password:");

        jLabel7.setText("Confirm Pass:");

        jLabel8.setText("Address:");

        txtStaffUsername.setEnabled(false);

        cbbStaffDepartment.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbStaffDepartmentItemStateChanged(evt);
            }
        });

        txtStaffFirstName.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtStaffFirstNameFocusLost(evt);
            }
        });

        txtStaffAddID.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtStaffAddIDFocusLost(evt);
            }
        });

        jLabel9.setText("Phone No:");

        rdbStaffMale.setSelected(true);
        rdbStaffMale.setText("Male");

        jLabel10.setText("Gender:");

        rdbStaffFemale.setText("Female");

        jLabel11.setText("Education:");

        cbbStaffSpecialization.setEnabled(false);

        lblStaffSpecialization.setText("Specialization:");
        lblStaffSpecialization.setToolTipText("");

        taStaffAdress.setColumns(20);
        taStaffAdress.setRows(5);
        jScrollPane7.setViewportView(taStaffAdress);

        btnStaffAction.setText("Add");
        btnStaffAction.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnStaffActionActionPerformed(evt);
            }
        });

        jButton2.setText("Cancel");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel12.setText("Date of Birth:");

        cbbStaffYear.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1990" }));
        cbbStaffYear.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbStaffYearItemStateChanged(evt);
            }
        });

        cbbStaffMonth.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));
        cbbStaffMonth.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbStaffMonthItemStateChanged(evt);
            }
        });

        cbbStaffDay.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        javax.swing.GroupLayout pnlStaffAddLayout = new javax.swing.GroupLayout(pnlStaffAdd);
        pnlStaffAdd.setLayout(pnlStaffAddLayout);
        pnlStaffAddLayout.setHorizontalGroup(
            pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlStaffAddLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblStaffSpecialization)
                    .addGroup(pnlStaffAddLayout.createSequentialGroup()
                        .addGap(54, 54, 54)
                        .addComponent(btnStaffAction, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButton2))
                    .addGroup(pnlStaffAddLayout.createSequentialGroup()
                        .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)
                            .addComponent(jLabel8)
                            .addComponent(jLabel10)
                            .addComponent(jLabel12)
                            .addComponent(jLabel11))
                        .addGap(20, 20, 20)
                        .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(pnlStaffAddLayout.createSequentialGroup()
                                .addComponent(cbbStaffYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cbbStaffMonth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cbbStaffDay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
                            .addComponent(cbbStaffDepartment, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtStaffLastName)
                            .addComponent(txtStaffFirstName)
                            .addComponent(txtStaffUsername, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(pssPassword, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
                            .addComponent(pssPassConfirm, javax.swing.GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)
                            .addGroup(pnlStaffAddLayout.createSequentialGroup()
                                .addComponent(rdbStaffMale)
                                .addGap(18, 18, 18)
                                .addComponent(rdbStaffFemale))
                            .addComponent(txtStaffAddID, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtStaffEducation)
                            .addComponent(cbbStaffSpecialization, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtStaffPhoneNo)))
                    .addComponent(jLabel9))
                .addContainerGap(38, Short.MAX_VALUE))
        );
        pnlStaffAddLayout.setVerticalGroup(
            pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlStaffAddLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtStaffAddID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtStaffFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtStaffLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbbStaffDepartment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtStaffUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pssPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pssPassConfirm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlStaffAddLayout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(jLabel9))
                    .addGroup(pnlStaffAddLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtStaffPhoneNo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(5, 5, 5)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdbStaffMale)
                    .addComponent(jLabel10)
                    .addComponent(rdbStaffFemale))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(cbbStaffYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbStaffMonth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbStaffDay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(txtStaffEducation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblStaffSpecialization)
                    .addComponent(cbbStaffSpecialization, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlStaffAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnStaffAction)
                    .addComponent(jButton2))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        getContentPane().add(pnlStaffAdd, java.awt.BorderLayout.WEST);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cbbStaffDepartmentItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbStaffDepartmentItemStateChanged
        // TODO add your handling code here:
        if (cbbStaffDepartment.getSelectedItem().toString().equalsIgnoreCase("Tester")) {
            cbbStaffSpecialization.setEnabled(true);
            lblStaffSpecialization.setText("Tech Skill:");
            cbbStaffSpecialization.setModel(db.getListTechSkill(con));

        }else if(cbbStaffDepartment.getSelectedItem().toString().equalsIgnoreCase("Doctor")) {
            cbbStaffSpecialization.setEnabled(true);
            lblStaffSpecialization.setText("Specialization:");
            cbbStaffSpecialization.setModel(db.getListSpecialization(con));

        }else{
            cbbStaffSpecialization.setEnabled(false);
            cbbStaffSpecialization.setModel(new DefaultComboBoxModel());
        }
}//GEN-LAST:event_cbbStaffDepartmentItemStateChanged

    private void txtStaffFirstNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtStaffFirstNameFocusLost
        // TODO add your handling code here:
        txtStaffUsername.setText(txtStaffFirstName.getText()+"_"+txtStaffAddID.getText());
}//GEN-LAST:event_txtStaffFirstNameFocusLost

    private void txtStaffAddIDFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtStaffAddIDFocusLost
        // TODO add your handling code here:
        txtStaffUsername.setText(txtStaffFirstName.getText()+"_"+txtStaffAddID.getText());
}//GEN-LAST:event_txtStaffAddIDFocusLost

    private void btnStaffActionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStaffActionActionPerformed
        // TODO add your handling code here:
        if (txtStaffPhoneNo.getText().length() != 0) {
            try {
                String num = txtStaffPhoneNo.getText();

                if (num.length() > 10) {
                    String num1 = num.substring(0, num.length() / 2);
                    String num2 = num.substring(num.length() / 2, num.length());
                    int it_av = Integer.parseInt(num1);
                    int it_av2 = Integer.parseInt(num2);

                    if (it_av == 0) {
                        return;

                    }
                } else {
                    int it_av = Integer.parseInt(num);

                    if (it_av == 0) {
                        return;

                    }
                }

            } catch (NumberFormatException e) {
                JOptionPane.showMessageDialog(this, "Phone must digit only!");
                return;
            }
        }


        if (txtStaffAddID.getText().length() != 6) {
            //Kiển tra nếu nhập vào ko đúng 6 ký tự thì báo lỗi

            JOptionPane.showMessageDialog(this, "Staff's ID must have exactly six character!");
        }else if(db.searchStaff(con, 1, txtStaffAddID.getText()).getRowCount() != 0){
            // Kiểm tra xem có Patient này ko, dùng method search Patient theo PatientID
            // trả về PikaTableModel, rồi xem PikatableModel này có số row == 0 hay ko?
            // Nếu số Row == 0 tức là ko có Patient với PatientID này

            JOptionPane.showMessageDialog(this, "This Staff's ID existed!");
        }else if (txtStaffFirstName.getText().length() == 0) {
            //Kiển tra nếu nhập vào ko đúng 3 ký tự thì báo lỗi

            JOptionPane.showMessageDialog(this, "Staff's first name must have!");
        } else if (txtStaffLastName.getText().length() == 0) {
            //Kiển tra nếu nhập vào ko đúng 3 ký tự thì báo lỗi

            JOptionPane.showMessageDialog(this, "Staff's last name must have!");
        }else if (pssPassword.getText().length() < 6) {
            //Kiển tra nếu nhập vào ko đúng 6 ký tự thì báo lỗi

            JOptionPane.showMessageDialog(this, "Password must have more than six character!");
        }else if (pssPassword.getText().compareTo(pssPassConfirm.getText()) != 0) {
            //Kiển tra nếu nhập vào ko đúng 6 ký tự thì báo lỗi

            JOptionPane.showMessageDialog(this, "Confirm Password does not same as Password!");
        } else if (txtStaffPhoneNo.getText().length() > 13) {
            //Kiển tra nếu nhập vào ko đúng 6 ký tự thì báo lỗi

            JOptionPane.showMessageDialog(this, "Phone number must not have more than 13 digits!");
        } else {
            // Trong add bill này CollectorID có thể để trống nên ko cần kiểm tra

            // Nếu toàn bộ quá trình kiểm tra ko sai thì bắt đầu add vào

            // Tạo mới một Object Bill để chứa thông tin
            staf = new Staff();

            staf.setStaffID(txtStaffAddID.getText());
            staf.setFirstName(txtStaffFirstName.getText());
            staf.setLastName(txtStaffLastName.getText());

            if (cbbStaffDepartment.getSelectedItem().toString().equalsIgnoreCase("Server Admin")) {
                staf.setDepartmentID("ADM");
                staf.setTechSkillID("NON");
                staf.setSpecialID("NON");
            } else if (cbbStaffDepartment.getSelectedItem().toString().equalsIgnoreCase("Patient Register")) {
                staf.setDepartmentID("PRG");
                staf.setTechSkillID("NON");
                staf.setSpecialID("NON");
            } else if (cbbStaffDepartment.getSelectedItem().toString().equalsIgnoreCase("Tester")) {
                staf.setDepartmentID("TER");
                staf.setSpecialID("NON");
                staf.setTechSkillID(db.searchTechSkill(con, 2, cbbStaffSpecialization.getSelectedItem().toString()).getValueAt(0, 0).toString());
            } else if (cbbStaffDepartment.getSelectedItem().toString().equalsIgnoreCase("Doctor")) {
                staf.setDepartmentID("DOC");
                staf.setTechSkillID("NON");
                staf.setSpecialID(db.searchSpecialization(con, 2, cbbStaffSpecialization.getSelectedItem().toString()).getValueAt(0, 0).toString());
            }

            staf.setUsername(txtStaffUsername.getText());

            MD5Passing passing = new MD5Passing();

            staf.setPassword(passing.makePass(pssPassword.getText()));

            staf.setAddress(taStaffAdress.getText());

            staf.setPhoneNo(txtStaffPhoneNo.getText());

            if (rdbStaffMale.isSelected()) {
                staf.setGender(true);
            } else {
                staf.setGender(false);
            }

            PikaDate pik = new PikaDate();

            pik.setYear(Integer.parseInt(cbbStaffYear.getSelectedItem().toString()));

            pik.setMonth(Integer.parseInt(cbbStaffMonth.getSelectedItem().toString()));

            pik.setDate(Integer.parseInt(cbbStaffDay.getSelectedItem().toString()));

            staf.setDateOfBirth(pik);

            staf.setEdu_qual(txtStaffEducation.getText());

            this.setVisible(false);

            // DateMade và DatePaid ko phải làm vì tớ đã sửa lại method add trong
            // DBManager, sẽ lấy ngày hiện tại
            // Report có DateMade tương tự cũng được tớ sủa method rồi
        }
}//GEN-LAST:event_btnStaffActionActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
}//GEN-LAST:event_jButton2ActionPerformed

    private void cbbStaffYearItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbStaffYearItemStateChanged
        // TODO add your handling code here:
        PikaDate pika = new PikaDate();
        int month = Integer.parseInt(cbbStaffMonth.getSelectedItem().toString());
        int year = Integer.parseInt(cbbStaffYear.getSelectedItem().toString());
        cbbStaffDay.setModel(pika.getDayByMonth(month, year));
}//GEN-LAST:event_cbbStaffYearItemStateChanged

    private void cbbStaffMonthItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbStaffMonthItemStateChanged
        // TODO add your handling code here:
        PikaDate pika = new PikaDate();
        int month = Integer.parseInt(cbbStaffMonth.getSelectedItem().toString());
        int year = Integer.parseInt(cbbStaffYear.getSelectedItem().toString());
        cbbStaffDay.setModel(pika.getDayByMonth(month, year));
}//GEN-LAST:event_cbbStaffMonthItemStateChanged

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                dlgAddStaff dialog = new dlgAddStaff(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    /**
     * Biến chứa staff
     */
    private Staff staf;

    /**
     * Method lấy staff
     * @return
     */
    public Staff getStaf() {
        return staf;
    }

    /**
     * Method gán giá trị cho Staff
     * @param staf
     */
    public void setStaf(Staff staf) {
        this.staf = staf;
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnStaffAction;
    private javax.swing.JComboBox cbbStaffDay;
    private javax.swing.JComboBox cbbStaffDepartment;
    private javax.swing.JComboBox cbbStaffMonth;
    private javax.swing.JComboBox cbbStaffSpecialization;
    private javax.swing.JComboBox cbbStaffYear;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JLabel lblStaffSpecialization;
    private javax.swing.JPanel pnlStaffAdd;
    private javax.swing.JPasswordField pssPassConfirm;
    private javax.swing.JPasswordField pssPassword;
    private javax.swing.JRadioButton rdbStaffFemale;
    private javax.swing.JRadioButton rdbStaffMale;
    private javax.swing.JTextArea taStaffAdress;
    private javax.swing.JTextField txtStaffAddID;
    private javax.swing.JTextField txtStaffEducation;
    private javax.swing.JTextField txtStaffFirstName;
    private javax.swing.JTextField txtStaffLastName;
    private javax.swing.JTextField txtStaffPhoneNo;
    private javax.swing.JTextField txtStaffUsername;
    // End of variables declaration//GEN-END:variables

}
